home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK2.toast / Development Kits (Disc 2) / QuickDraw GX / Programming Stuff / Sample Code / Printing Samples / Printer Drivers… / Generic LaserWriter / Generic LaserWriter.c < prev    next >
Encoding:
Text File  |  1995-04-10  |  2.7 KB  |  136 lines  |  [TEXT/MPS ]

  1. /*-----------------------------------------------------------------------------
  2.  
  3.     Generic LaserWriter.c
  4.     
  5.         This part of the driver demonstrates how to force the PostScript
  6.         imaging system to copy its output to a file.
  7.         
  8.      12/18/93 - dmh - Removed IIg-dependencies for b3.
  9.         9/13/93 - dmh - Updated for the b2 seed.
  10.         9/14/93 - dmh - Disabled the PostScript log which was created in
  11.                                         the Extensions folder.
  12.         3/22/94 - dmh - Balanced gxInitialize override with a gxShutDown one.
  13.         
  14.     © 1991-1994 Apple Computer Inc.
  15.     
  16. -----------------------------------------------------------------------------*/
  17.  
  18. // If non-zero, we create a PostScript log in the Extensions folder.
  19.  
  20. #define CREATELOG    0
  21.  
  22. #include <PrintingDrivers.h>
  23. #include <GXExceptions.h>
  24.  
  25. extern long A5Size (void);
  26. extern void A5Init (void *);
  27.  
  28.  
  29. // Globals...
  30.  
  31. short gLogRefNum;
  32.  
  33.  
  34. OSErr DriverPostScriptDoPageSetup(    gxFormat theFormat,
  35.                                                                          long     pageindx,
  36.                                                                         gxPostScriptImageDataHdl imageDataHdl )
  37. {
  38.     OSErr status;
  39.     char    *setupcommand = "\p%% File For Level-I or Level-II.\n";
  40.     
  41.     require(CREATELOG, Not_Logging);
  42.     status = Send_GXBufferData( & setupcommand[ 1 ], setupcommand[ 0 ], nil );
  43.     nrequire( status, BufferCommandFailed );
  44.     
  45. Not_Logging:
  46.     
  47.     status = Forward_GXPostScriptDoPageSetup( theFormat, pageindx, imageDataHdl );
  48.     ncheck( status );
  49.     
  50. BufferCommandFailed:
  51.     return( status );
  52. }
  53.  
  54.  
  55.  
  56. OSErr DriverOpenConnection(void)
  57.     {
  58.         OSErr            status;
  59.                 
  60.         status = Forward_GXOpenConnection();
  61.         nrequire(status, failed_Forward);
  62.         require(CREATELOG, Not_Logging);
  63.  
  64.         status = Create("\pPostScriptLog.ps", 0, 'MPS ', 'TEXT');
  65.         ncheck(status);
  66.         status = FSOpen("\pPostScriptLog.ps", 0, &gLogRefNum);
  67.         ncheck(status);
  68.                     
  69.         status = noErr;
  70.     
  71. Not_Logging:
  72. failed_Forward:
  73.         return(status);    
  74.     
  75.     }//DriverOpenConnection
  76.  
  77.  
  78. OSErr    DriverCloseConnection(void)
  79.     {
  80.         OSErr            status;
  81.         long            j;
  82.         
  83.         status = Forward_GXCloseConnection();
  84.         nrequire(status, failed_Forward);
  85.         require(CREATELOG, Not_Logging);
  86.  
  87.         GetFPos(gLogRefNum, &j);
  88.         SetEOF(gLogRefNum, j);
  89.         FSClose(gLogRefNum);
  90.  
  91. Not_Logging:
  92. failed_Forward:
  93.         return(status);
  94.     }
  95.  
  96.  
  97.  
  98. OSErr    DriverInitialize(void)
  99.     {
  100.         OSErr            status;
  101.         
  102.         status = NewMessageGlobals(A5Size(), A5Init);
  103.         nrequire(status, failed_a5);
  104.  
  105. failed_a5:        
  106.         return(status);
  107.     
  108.     }
  109.  
  110.  
  111. OSErr    DriverShutDown(void)
  112.     {
  113.         DisposeMessageGlobals();
  114.         return noErr;
  115.     }
  116.  
  117.  
  118. OSErr DriverDumpBuffer(gxPrintingBuffer *buffPtr)
  119.     {
  120.         OSErr                status;
  121.         long                count;
  122.                 
  123.         require(CREATELOG, Not_Logging);
  124.         count = buffPtr->size;
  125.         
  126.         status = FSWrite(gLogRefNum, &count, buffPtr->data);
  127.         nrequire(status, failed_Write);
  128.     
  129. Not_Logging:
  130.         status = Forward_GXDumpBuffer(buffPtr);
  131.         ncheck(status);
  132.     
  133. failed_Write:
  134.         return(status);
  135.     
  136.     }